<template>
  <div class="home">
    <div class="common-layout">
      <el-container>
        <el-header>
          <div class="header">
            <div class="header-title">
              <el-icon><PartlyCloudy /></el-icon>
              <h3>智慧物业管理系统</h3>
            </div>

            <div class="header-userMsg">
              <el-icon><Bell /></el-icon>
              <img src="../assets/images/user.png" class="userImg" />
              <span>{{JSON.stringify(user).substring(3,5)}}</span>
              <span @click="backBegin">退出</span>
            </div>
          </div>
        </el-header>
        <el-container>
          <el-aside width="200px">
            <el-menu active-text-color="#66ccff" :router="true">
              <!-- 先循环数据 -->
              <div v-for="v in power" :key="v.title">
                <!-- 第一层（有子级） -->
                <el-sub-menu :index="v.title" v-if="v.children">
                  <template #title>
                    <!-- <el-icon size="20px" color="#000"
                    ><component :is="v.icon"></component
                  ></el-icon> -->
                    <span>{{ v.title }}</span>
                  </template>
                  <!-- 第二层 （有子级）-->
                  <div v-for="v2 in v.children" :key="v2.title">
                    <el-sub-menu :index="v2.title" v-if="v2.children">
                      <template #title>
                        <!-- <el-icon size="20px" color="#000"
                    ><component :is="v.icon"></component
                  ></el-icon> -->
                        <span>{{ v2.title }}</span>
                      </template>
                      <!-- 第三层 -->
                      <el-menu-item
                        v-for="v3 in v2.children"
                        :key="v3.title"
                        :index="v3.href"
                      >
                        <template #title>
                          <!-- <el-icon size="20px" color="#000"
                    ><component :is="v.icon"></component
                  ></el-icon> -->
                          <span>{{ v3.title }}</span>
                        </template>
                      </el-menu-item>
                    </el-sub-menu>
                    <!-- 第二层（无子级） -->
                    <el-menu-item :index="v2.href" v-else>
                      <template #title>
                        <!-- <el-icon size="20px" color="#000"
                    ><component :is="v.icon"></component
                  ></el-icon> -->
                        <span>{{ v2.title }}</span>
                      </template>
                    </el-menu-item>
                  </div>
                </el-sub-menu>

                <!-- 第一层（无子级） -->
                <el-menu-item :index="v.href" v-else>
                  <template #title>
                    <!-- <el-icon size="20px" color="#000"
                    ><component :is="v.icon"></component
                  ></el-icon> -->
                    <span>{{ v.title }}</span>
                  </template>
                </el-menu-item>
              </div>
            </el-menu>
          </el-aside>
          <el-main>
            <RouterView></RouterView>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<script setup>
import { ref } from "@vue/reactivity";
import router from "../router";

let power = JSON.parse(sessionStorage.getItem("power"));
// console.log(power);

let user = sessionStorage.getItem("user");

let backBegin = () => {
  router.replace("/list/CommunityList");
};
</script>

<style lang="less">
.home {
  // font-family: 楷体;
  height: 100%;
  background: #f0f2f5;

  .common-layout {
    height: 100%;
    .el-container {
      height: 100%;
      .el-aside {
        .el-menu {
          background-color: #fcfcfc;
          height: 100%;
        }
        .router {
          font-size: 20px;
          line-height: 60px;
          span {
            margin-left: 50px;
          }
        }
      }
      .el-main {
        padding: 0;
        background: #f0f2f5;
      }
    }
  }
  .el-header {
    background: linear-gradient(
        207deg,
        rgba(62, 94, 125, 0.79) 39%,
        #29b3b9 71%
      ),
      linear-gradient(270deg, #2193b0 0%, #6dd5ed 100%);
    .header {
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #fcfcfc;
      .header-title {
        width: 200px;
        display: flex;
        justify-content: space-evenly;
        align-items: center;
      }
      .header-userMsg {
        cursor: pointer;
        width: 152px;
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        .userImg {
          width: 32px;
          height: 32px;
          border-radius: 50%;
          background-color: #001529;
        }
      }
    }
  }
}
</style>
